<template>
  <div id="quanxianZongheInfo" class="box">
    <div>
      <div class="display_flex box_search">
        <div class="display_flex margin_rignt">
          <p>权利人姓名：</p>
          <div>
            <el-input v-model="needInfo.applicantName" placeholder="请输入权利人姓名" />
          </div>
        </div>
        <div class="display_flex margin_rignt">
          <p>复垦片块：</p>
          <div>
            <el-select v-model="needInfo.landId" placeholder="请选择">
              <el-option
                v-for="(item,index) in options"
                :key="index"
                :label="item.landName"
                :value="item.landId"
              />
            </el-select>
          </div>
        </div>
        <div class="display_flex margin_rignt">
          <p>开始时间：</p>
          <div>
            <el-date-picker v-model="needInfo.startTime" value-format="yyyy-MM-dd" type="date" placeholder="选择日期"></el-date-picker>
          </div>
        </div>
        <div class="display_flex margin_rignt">
          <p>截止时间：</p>
          <div>
            <el-date-picker v-model="needInfo.finishTime" value-format="yyyy-MM-dd" type="date" placeholder="选择日期"></el-date-picker>
          </div>
        </div>
        <el-button @click="search" type="primary">查询</el-button>
      </div>
      <div class="table">
        <el-table :data="dataArr" border style="width: 100%" v-loading="isListLoading">
          <el-table-column type="index" show-overflow-tooltip label="序号" width="80"></el-table-column>
          <el-table-column prop="applicantName" label="权利人"></el-table-column>
          <el-table-column prop="landName" label="验收地块"></el-table-column>
          <el-table-column prop="place" label="位置"></el-table-column>
          <el-table-column prop="time" label="验收时间"></el-table-column>
          <el-table-column label="操作" fixed="right">
            <template slot-scope="scope">
              <!-- <template> -->
              <el-button
                size="mini"
                v-if="scope.row.time"
                type="text"
                @click="btnById(scope.row)"
              >查看</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="pages">
        <el-pagination
          @size-change="showSize"
          @current-change="showPage"
          :current-page="needInfo.page"
          :page-sizes="[5, 10, 20, 400]"
          :page-size="needInfo.size"
          layout="total, sizes, prev, pager, next, jumper"
          :total="totalPage"
        ></el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
import { supervisingInfo, supervisingCheck } from "@/api/quxianzongheYanshou";
import { getLandStatusMapAuditInfo } from "@/api/jjgc";
import tdMap from "@/components/tdMap";
export default {
  components: {
    tdMap
  },
  data() {
    return {
      checked: true,
      flag: 1,
      options: [],
      value: "",
      tableData: [
        {
          date: "",
          name: "",
          address: ""
        },
        {
          date: "",
          name: "",
          address: ""
        }
      ],
      currentPage4: 4,
      title: "",
      titlePath: "",
      seeImgDialog: false,
      imgArr: [],

      dataArr: [],
      needInfo: {
        page: 1,
        size: 10,
        landId: "",
        applicantName: "",
        startTime: "",
        finishTime: ""
      },
      totalPage: 0,
      landId: "",
      landData: null, //单条监管详情
      showImgType: null, //分辨视频图片

      isListLoading: false,
      mainDataData: []
    };
  },
  created() {
    this.getData();
    this.getDataSelect();
  },
  methods: {
    btnById(row) {
      if (row.yesOrNo == "YES") {
        this.checked = true;
      } else {
        this.checked = false;
      }
      this.landId = row.landId;
      this.$router.push({
        path: "/quxianzongheYanshou/supervisionInformation/detail",
        query: {
          id: row.landId,
          vcr: row.vcr ? row.vcr : "",
          photo: row.photo ? row.photo : "",
          coorDonate: row.coorDonate,
          landName: row.landName,
          time: row.time ? row.time : "",
          place: row.place ? row.place : "",
          checked: this.checked
        }
      });
      localStorage.setItem("zongheItem", JSON.stringify(row));
    },
    search(){
      this.needInfo.page = 1
      this.getData()
    },
    getData() {
      this.isListLoading = true;
      var data={}
      var objArr=this.needInfo
      for (var index in objArr) {
        if(objArr[index]!==''&&objArr[index]!=null){
          if(index == "startTime" || index == "finishTime"){
            data[index]=objArr[index] + " " + "00:00:00";
          }else{
            data[index]=objArr[index]
          }
        }
      }
      data["projectId"] = localStorage.getItem("projectId")
      supervisingInfo(data)
        .then(res => {
          this.isListLoading = false;
          this.dataArr = res.data.rows;
          this.totalPage = res.data.total;
        })
        .catch(() => {
          this.isListLoading = false;
        });
    },
    unique (arr) {
      return Array.from(new Set(arr))
    },
    getDataSelect(){
      var data={
        page:1,
        size:99999
      }
      data["projectId"] = localStorage.getItem("projectId")
      supervisingInfo(data)
        .then(res => {
          var result = [];
          var obj = {};
          for(var i =0; i<res.data.rows.length; i++){
            if(!obj[res.data.rows[i].landId]){
                result.push(res.data.rows[i]);
                obj[res.data.rows[i].landId] = true;
            }
          }
          console.log(result)
          
          this.options = result
        }).catch(() => {});
    },
    showSize(val) {
      this.needInfo.size = val;
      this.getData();
    },
    showPage(val) {
      this.needInfo.page = val;
      this.getData();
    },
    btnSeeImg(row) {
      this.title = row.name;
      this.titlePath = row.path;
      this.showImgType = row.type;
      this.seeImgDialog = true;
      var vedio = document.getElementById("showVedio");
      vedio.play();
    },
    handleSizeChange(val) {},
    handleCurrentChange(val) {}
  }
};
</script>

<style lang="scss" scoped>
.box {
  padding: 30px;
}
.display_flex {
  display: flex;
  align-items: center;
}
.box_search .display_flex p {
  font-size: 14px;
  color: #333333;
}
.margin_rignt {
  margin-right: 30px;
}
.table {
  margin: 20px 0px;
}

.landInfo {
  border: 1px solid #efefef;
  box-sizing: border-box;
}
.back {
  margin: 20px;
}
.title_one {
  text-align: center;
  line-height: 40px;
  font-size: 20px;
  color: #444;
  font-weight: bold;
}
.title_little {
  font-size: 13px;
  color: #999;
  margin: 40px 20px 20px 30px;
}
.title .title_little span {
  margin-right: 30px;
}
.project_title {
  background: #f8f8f8;
  height: 50px;
  background: #f8f8f8;
  padding: 0px 30px;
  line-height: 50px;
  color: #48494d;
  font-size: 14px;
  font-weight: bold;
  border-top: 1px solid #efefef;
  border-bottom: 1px solid #efefef;
}
.project_img {
  padding: 30px;
}
.seeImg {
  text-align: center;
}
.project_result {
  padding: 30px;
}
.project_result .display_flex {
  margin-bottom: 20px;
  font-size: 13px;
  color: #444;
  width: 180px;
}
.project_result .display_flex p {
  font-size: 14px;
  color: #444444;
  font-weight: bold;
}
#quanxianZongheInfo
  /deep/ .el-checkbox__input.is-disabled
  + span.el-checkbox__label {
  border-color: #409eff;
}
#quanxianZongheInfo
  /deep/ .el-checkbox__input.is-disabled.is-checked
  .el-checkbox__inner {
  border-color: #409eff;
  background-color: #409eff;
}
#quanxianZongheInfo
  /deep/ .el-checkbox__input.is-disabled.is-checked
  .el-checkbox__inner::after {
  border-color: #fff;
}
#quanxianZongheInfo
  /deep/ .el-checkbox__input.is-disabled
  + span.el-checkbox__label {
  color: #12203e;
}
.pages {
  text-align: center;
}
.mapBox_right {
  width: 600px;
  height: 600px;
  margin-top: 30px;
}
</style>